<template>
  <div>
    <me-header></me-header>
    <menubar></menubar>
  </div>
</template>

<script>
  import menubar from '../../components/MenuBar.vue'
  import MeHeader from './base/MeHeader.vue'
  import {
    mapState,
    mapMutations
  } from 'vuex'
  export default {
    components: {
      menubar,
      MeHeader
    },
    methods: {
      ...mapMutations(['SET_ORDER', 'SET_ADDRESS']),
      async getOrder() {
        await this.$api.homeData.order().then(res => {
          if (res.code === 200) {
            this.SET_ORDER(res.data)
          } else {
            alert('请求失败')
          }
        })
      },
      async getUserAdress() {
        this.$api.homeData.userAddress().then(({
          data
        }) => {
          this.SET_ADDRESS(data)
        })
      }
    },
    created() {
      this.getOrder()
      this.getUserAdress()
    },
    computed: {
      ...mapState(["loginToken", 'order'])
    }
  }
</script>

<style scoped>
</style>
